package com.fzfnn.scrapbook.mapper.provider;

import com.fzfnn.scrapbook.entity.User;
import org.apache.ibatis.jdbc.SQL;

public class UserSqlProvider {

    public String updateUser(final User user) {
        return new SQL() {{
            UPDATE("user");
            if (user.getUsername() != null) {
                SET("username = #{username}");
            }
            if (user.getPassword() != null) {
                SET("password = #{password}");
            }
            if (user.getEmail() != null) {
                SET("signature = #{signature}");
            }
            WHERE("user_id = #{userId}");
        }}.toString();
    }
}
